package com.intellagric.service.search.listener;

import com.intellagric.service.search.agriecom.AgriecomNewsSearch;
import org.springframework.beans.factory.annotation.Autowired;

import javax.jms.*;

public class NewsChangeListener implements MessageListener {

    @Autowired
    private AgriecomNewsSearch newsSearch;

    @Override
    public void onMessage(Message message) {
        if(message instanceof TextMessage){
            TextMessage textMessage=(TextMessage)message;
            String id="";
            try {
                id=textMessage.getText();
                newsSearch.addNews(id);
            } catch (JMSException e) {
                e.printStackTrace();
            }
        }
    }
}
